home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Mark Pilgrim / Ghost 1.0 / source / Ghost ƒ / Ghost code / ghost generic open.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-30  |  1.9 KB  |  70 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        ghost generic open.c
  4.  
  5. Purpose:    This module handles opening saved games via apple events.
  6.  
  7.  
  8. Ghost -=- a classic word-building challenge
  9. Copyright (C) 1993 Mark Pilgrim
  10.  
  11. This program is free software; you can redistribute it and/or modify
  12. it under the terms of the GNU General Public License as published by
  13. the Free Software Foundation; either version 2 of the License, or
  14. (at your option) any later version.
  15.  
  16. This program is distributed in the hope that it will be useful,
  17. but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19. GNU General Public License for more details.
  20.  
  21. You should have received a copy of the GNU General Public License
  22. along with this program in a file named "GNU General Public License".
  23. If not, write to the Free Software Foundation, 675 Mass Ave,
  24. Cambridge, MA 02139, USA.
  25.  
  26. \**********************************************************************/
  27.  
  28. #include "ghost globals.h"
  29. #include "ghost generic open.h"
  30. #include "ghost load-save.h"
  31. #include "ghost error.h"
  32. #include "msg environment.h"
  33. #include "msg dialogs.h"
  34.  
  35. void GenericOpen(FSSpec *myFSS)
  36. {
  37.     int            resultCode;
  38.     
  39.     if (!gInProgress)
  40.     {
  41.         switch (GetFileType(myFSS))
  42.         {
  43.             case SAVE_TYPE:
  44.                 gameFile=*myFSS;
  45.                 HandleError(GetSavedGame(&gameFile));
  46.                 break;
  47.         }
  48.     }
  49.     else
  50.     {
  51.         PositionDialog('ALRT', generalAlert);
  52.         ParamText("\pPlease close the current game before loading a new one.","\p","\p","\p");
  53.         StopAlert(generalAlert, 0L);
  54.     }
  55. }
  56.  
  57. OSType GetFileType(FSSpec *myFSS)
  58. {
  59.     HParamBlockRec    paramBlock;
  60.     
  61.     paramBlock.fileParam.ioCompletion=0L;
  62.     paramBlock.fileParam.ioNamePtr=myFSS->name;
  63.     paramBlock.fileParam.ioVRefNum=myFSS->vRefNum;
  64.     paramBlock.fileParam.ioFDirIndex=0;
  65.     paramBlock.fileParam.ioDirID=myFSS->parID;
  66.     PBHGetFInfo(¶mBlock, FALSE);
  67.  
  68.     return paramBlock.fileParam.ioFlFndrInfo.fdType;
  69. }
  70.